﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/layout.Master" EnableEventValidation="false" EnableViewState="true" AutoEventWireup="true" CodeBehind="RSAdHocInvoice.aspx.cs" Inherits="mojoPortal.Web.RS.SBM.RSAdHocInvoice" %>
<%@ Register Src="~/rs/controls/modalactionmessagecontrol.ascx" TagName="ModalActionMessageControl" TagPrefix="uc1" %>



<asp:Content ID="Content1" ContentPlaceHolderID="leftContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
    <div>
    <table>
    <tr>
    <td><asp:Label ID="lblCompanyName" runat="server" Text="" Font-Bold="True" Font-Size="Medium"></asp:Label></td>
    <td></td>
    </tr>
    <tr>
    <td><asp:Literal ID="litCompanyFullAddress" runat="server" Text=""></asp:Literal></td>
    <td align="right">
    <table>
    <tr><td align="right">Due Date:</td><td><asp:TextBox ID="txtDueDate" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredField_txtDueDate" runat="server" ErrorMessage="Required" ControlToValidate="txtDueDate" ForeColor="Red" ValidationGroup="CreateInvoiceValidationGroup"></asp:RequiredFieldValidator>
    </td></tr>
    <tr><td align="right">Invoice Num:</td><td><asp:TextBox ID="txtInvoiceNum" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredField_txtInvoiceNum" runat="server" ErrorMessage="Required" ControlToValidate="txtInvoiceNum" ForeColor="Red" ValidationGroup="CreateInvoiceValidationGroup"></asp:RequiredFieldValidator>
    </td></tr>
    <tr><td align="right">PO Num:</td><td><asp:TextBox ID="txtPONum" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredField_txtPONum" runat="server" ErrorMessage="Required" ControlToValidate="txtPONum" ForeColor="Red" ValidationGroup="CreateInvoiceValidationGroup"></asp:RequiredFieldValidator>
    </td></tr>
    </table>
    </td>
    </tr>
    <tr><td colspan="3"><br /></td></tr>
    <tr><td align="right">Job Address:</td><td colspan="2">
        <asp:DropDownList ID="ddlJobAddress" runat="server" Visible="false" Width="500px" OnSelectedIndexChanged="ddlJobAddress_OnSelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
        <asp:TextBox ID="txtJobAddress" runat="server" Width="500px" BackColor="Gainsboro" ReadOnly="true" Visible="false"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredField_ddlJobAddress" runat="server" ErrorMessage="Required" ControlToValidate="ddlJobAddress" InitialValue="0" ForeColor="Red" ValidationGroup="CreateInvoiceValidationGroup"></asp:RequiredFieldValidator>
        <asp:RequiredFieldValidator ID="RequiredField_txtJobAddress" runat="server" ErrorMessage="Required" ControlToValidate="txtJobAddress" ForeColor="Red" ValidationGroup="CreateInvoiceValidationGroup"></asp:RequiredFieldValidator>
    </td></tr>
    <tr>
    <td align="right" valign="bottom">Bill To:</td><td colspan="2">
        <asp:DropDownList ID="ddlBillingContact" runat="server" OnSelectedIndexChanged="ddlBillingContact_OnSelectedIndexChanged" AutoPostBack="true" AppendDataBoundItems="true"><asp:ListItem Text="< Please Select >" Value="0" /></asp:DropDownList>
        <asp:TextBox ID="txtBillingAddress" runat="server" Width="370px" BackColor="Gainsboro" ReadOnly="true"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredField_txtBillingAddress" runat="server" ErrorMessage="Required" ControlToValidate="txtBillingAddress" ForeColor="Red" ValidationGroup="CreateInvoiceValidationGroup"></asp:RequiredFieldValidator>
    </td>
    </tr>
    <tr><td colspan="3"><br /></td></tr>
    <tr><td align="right">Additional Instruction:</td><td colspan="2"><asp:TextBox ID="txtAdditionalInstruction" runat="server" Width="500px"></asp:TextBox></td></tr>
    <tr><td align="right">Terms:</td><td colspan="2"><asp:TextBox ID="txtTerms" runat="server" Width="500px"></asp:TextBox></td></tr>
    <tr><td colspan="3"><br /></td></tr>
    </table>
    <ajaxToolkit:CalendarExtender ID="CalendarExtender_DueDate" runat="server" TargetControlID="txtDueDate"></ajaxToolkit:CalendarExtender>

    <table>
    <tr>
    <td>Description<br /><asp:DropDownList ID="ddlItemType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlItemType_OnSelectedIndexChanged"><asp:ListItem></asp:ListItem><asp:ListItem>WorkOrder</asp:ListItem><asp:ListItem>Task</asp:ListItem><asp:ListItem>Part</asp:ListItem></asp:DropDownList>
        <asp:TextBox ID="txtItemName" runat="server" Width="400px" Enabled="false" BackColor="Gainsboro"></asp:TextBox></td>
    <td>Amount<br /><asp:TextBox ID="txtAmount" runat="server" Width="80px" Enabled="false" BackColor="Gainsboro"></asp:TextBox></td>
    <td valign="bottom"><asp:Button ID="btnAddInvoiceItem" runat="server" Text="Add Invoice Item" onclick="btnAddInvoiceItem_Click" Enabled="false" /></td>
    </tr>
    </table>
        <div class="page">
        <asp:GridView ID="gvInvoiceItems" runat="server" AutoGenerateColumns="False" 
        AllowPaging="True" CellPadding="4" AllowSorting="True" DataKeyNames="ItemName"
        ForeColor="#333333" GridLines="None" Width="100%" >
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="">
            <ItemTemplate>
                <asp:LinkButton ID="lnkRemoveItem" CommandArgument='<%# Eval("ItemName") %>' OnCommand="gvInvoiceItems_Remove" runat="server" CausesValidation="false">
                <asp:Image runat="server" ID="deleteImage" ImageUrl="~/RS/Images/delete.gif" AlternateText="Delete" />
                </asp:LinkButton>
                <ajaxToolkit:ConfirmButtonExtender ID="Confirm_btnDelete" runat="server" TargetControlID="lnkRemoveItem" ConfirmText="Are you sure you want to remove this Item?" />
            </ItemTemplate>
            <HeaderStyle HorizontalAlign="Left" />
            </asp:TemplateField>
        
            <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" HeaderStyle-HorizontalAlign="Left"/>
            <asp:BoundField DataField="ItemType" HeaderText="Type" SortExpression="ItemType" HeaderStyle-HorizontalAlign="Left" />
            <asp:BoundField DataField="ItemName" HeaderText="Description" SortExpression="ItemName" HeaderStyle-HorizontalAlign="Left"/>
            <asp:BoundField DataField="UnitPrice" HeaderText="Rate" SortExpression="UnitPrice" HeaderStyle-HorizontalAlign="Left"/>
            <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" HeaderStyle-HorizontalAlign="Left"/>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#89A8E0" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#89A8E0" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
        <EmptyDataTemplate><br />
        <center>
        <asp:Label ID="lblNoRecordFound" runat="server" Text="No Item Has Been Added" ForeColor="Silver" Font-Bold="True"></asp:Label>
        </center>
        </EmptyDataTemplate>
        </asp:GridView>
        </div>
        <asp:Button ID="btnCreateInvoice" runat="server" Text="Create Invoice" OnClick="btnCreateInvoice_OnClick" ValidationGroup="CreateInvoiceValidationGroup" />
        <asp:Button ID="btnResetInvoiceItem" runat="server" Text="Reset" OnClick="btnResetInvoiceItem_OnClick" CausesValidation="false" />
    </div>

    <uc1:ModalActionMessageControl ID="ucModalActionMessageControl" runat="server"/>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="rightContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="pageEditContent" runat="server">
</asp:Content>
